#lang racket

(define (cube x) (* x x x))

(define (square x) (* x x))

(define (good-enough? guess x)
  (< (abs (- (cube guess) x)) 0.001))

(define (imrove guess x)
  (/ (+ (/ x (square guess)) (* 2 guess)) 3))

(define (cube-root-iter guess x)
  (if (good-enough? guess x)
      guess
      (cube-root-iter (imrove guess x) x)))

(define (cube-root x)
  (cube-root-iter 1.0 x))

(cube-root 9)